<?php

class CQuestionsubject extends Zend_Db_Table
{

    protected $_name;

    protected $_primary;

    public function _setup()
    {

        $this->_name=R_PRE."Question_subject";

        $this->_primary="id";

        parent::_setup();

    }

    public function createQuestionsubject($data)
    {

        $this->insert($data);

        return true;

    }

    public function editFbscence($id,$data)
        {
		$db=$this->getAdapter();

		$where = $db->quoteInto('id = ?', $id);

		$rows_affected=$db->update($this->_name,$data,$where);

		if($rows_affected!=1){

			return false;

		}else{

			return true;

		}
        }

    public function getsubjectdetail($id){
        
        $db=$this->getAdapter();
        $select = $db->select();

        $select->from($this->_name,'*');
        
        $select->where($this->_name.'.id = ? ',$id);
        return $db->fetchAll($select);

    }

    public function getsubject($from,$counts,$where=''){

        $db=$this->getAdapter();
        $select = $db->select();

        $select->from($this->_name,'*');

        if($where!=''){

			$select->where($where);

	}

        if($counts!=0){

            $select->limit($counts, $from);

        }
        return $db->fetchAll($select);

    }


    public function getAllsubject($where=''){

            $db=$this->getAdapter();

            $select = $db->select();

            $select->from($this->_name,'COUNT(*)');

            if($where!=''){

                    $select->where($where);

            }

            return $db->fetchOne($select);

    }

    public function delsubject($scenceidArray){

            $db=$this->getAdapter();

            $scenceidString=join(',',$scenceidArray);
            $result=$db->query("DELETE FROM $this->_name WHERE id IN ($scenceidString)");

            return $result;

    }
}